//  const url_all = {
// 	'DEV': 'http://192.168.0.110:8082', // 开发
// 	'PRO': 'http://129.211.213.59:8082', // 生产
// }
// let baseUrl = url_all['DEV'] // 调整当前环境
let baseUrl = '/api'

/*#ifndef  H5*/
// baseUrl= 'http://43.143.228.240:8081';
baseUrl = 'http://127.0.0.1:8081'
// baseUrl= 'https://www.hhac.work/';
/*#endif*/
export const uploadFile = (filePath: string, url: string, formData: any) => {
  return new Promise((resolve, reject) => {
    const userStore = uni.getStorageSync('token')
    uni.uploadFile({
      url: `${baseUrl}${url}`,
      filePath: filePath,
      name: 'file', // 文件对应的 key
      timeout: 60000,
      formData: formData,
      header: {
        Authorization: userStore,
      },
      success: (res) => {
        if (res.data) {
          resolve(JSON.parse(res.data))
        }
      },
      fail: (err) => {
        uni.showToast({
          title: '网络异常',
          icon: 'none',
          duration: 5000,
        })
        reject(err)
      },
    })
  })
}
